TypeVar
Table of Content
TypeVar#
from typing import TypeVar
T = TypeVar("T")
def foo(arg: T) -> T:
return arg
import decimal
from typing import TypeVar
Number = TypeVar("Number", int, float, decimal.Decimal)
def double(value: Number) -> Number:
return value * 2
result: int
result = double(5)